const path=require('path');
const HtmlWebpackPlugin=require('html-webpack-plugin');
const webpack = require('webpack');
const CleanWebpackPlugin=require('clean-webpack-plugin');
module.exports={
	entry:
	//['./src/index.js','./src/index2.js'],
	{
		index:'./src/index.js',
		//index2:'./src/index2.js'                MiniCssExtractPlugin.loader,

	},
	output:{
		path:path.resolve(__dirname,'dist'),
		filename:'[name].bundle.js'
	},
	module: {
	    rules: [
	      {
	        test:/\.css$/,
	        use:['style-loader','css-loader']
	      },
	      {
	        test:/\.less$/,
	        use:['style-loader','css-loader','less-loader']
	      },
	      {
	        test:/\.(scss|sass)$/,
	        use:['style-loader','css-loader','sass-loader']
	      },
	      {
	      	test:/\.(jpg|png|gif)$/,
	      	use:[
	      		{
	      			loader:'url-loader',
	      			options:{
	      				limit:500000
	      			}
	      		}
	      	]
	      }
	    ]
	  },
	plugins:[
		new webpack.HotModuleReplacementPlugin(),
		new HtmlWebpackPlugin({
			//chunks:['index'],
			filename:'index.html',
			// minify:{
			// 	collapseWhitespace:true,
			// 	removeAttributeQuites:true
			// },
			hash:true,
			title:'第一个webpack-demo',
			template:'./src/index.html'
		}),
		// new HtmlWebpackPlugin({
		// 	chunks:['index2'],
		// 	filename:'index2.html',
		// 	// minify:{
		// 	// 	collapseWhitespace:true,
		// 	// 	removeAttributeQuites:true
		// 	// },
		// 	hash:true,
		// 	title:'第一个webpack-demo',
		// 	template:'./src/index2.html'
		// }),
		new CleanWebpackPlugin(['dist']),
		
	],
	devServer:{
		//自动打开浏览器
		open:true,
		//设置服务器的访问目录
		contentBase:path.resolve(__dirname,'dist'),
		//服务器ip地址
		host:'localhost',
		//设置端口
		port:8088,
		//热更新
		hot:true
	}
}